package com.pattern.command.tenant;

import com.pattern.command.frame.Command;
import com.pattern.command.third.Service3;

public class Command3 implements Command {
    private Command1 cmd1;
    private Command2 cmd2;

    public Command3(Command1 cmd1, Command2 cmd2) {
        this.cmd1 = cmd1;
        this.cmd2 = cmd2;
    }

    @Override
    public boolean execute() {
        System.out.println("Command3::execute() param: userId="+cmd1.getUserId()+", orderId=" + cmd2.getOrderId());
        return Service3.bindUserOrder(cmd1.getUserId(), cmd2.getOrderId());
    }

    @Override
    public boolean undo() {
        System.out.println("Command3::undo() param: userId="+cmd1.getUserId()+", orderId=" + cmd2.getOrderId());
        return Service3.unbindUserOrder(cmd1.getUserId(), cmd2.getOrderId());
    }
}
